package com.jingan.nursinghome.regulatory.view;

import android.app.Activity;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.jingan.nursinghome.regulatory.data.MicrometerTable;
import com.jingan.nursinghome.regulatory.dialog.CreateMicrometerTableDailog;

import cn.android.support.v7.lib.sin.crown.utils.ProportionUtils;


/**
 * Created by Administrator on 2017/5/21.
 */

public class MySpacesItemDecoration extends RecyclerView.ItemDecoration {
    private int space=0;

    public MySpacesItemDecoration(Activity activity, int space) {
        this.space = (int) (space* ProportionUtils.getInstance().getHorizontalProportion());
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);
        //设置RecyClerView子item项左右边距
        outRect.left = space;
        outRect.right = space;
        int position = parent.getChildLayoutPosition(view);//获取当前view的下标位置,下标从0开始

        if(MicrometerTable.getInstance().getTopics(CreateMicrometerTableDailog.rid,CreateMicrometerTableDailog
                .jlyName).get(position).getIndex()==null){
            return;
        }
        if (MicrometerTable.getInstance().getTopics(CreateMicrometerTableDailog.rid,CreateMicrometerTableDailog
                .jlyName).get(position).getIndex().trim().equals("0")){
            outRect.top=ProportionUtils.getInstance().adapterInt(20);
        }else {
            outRect.top=ProportionUtils.getInstance().adapterInt(0);
        }
    }
}
